# coding=utf-8
import time

import yaml
from selenium import webdriver

# 获取cookies并并保存到本地
# def test_get_cookies():
dirver = webdriver.Chrome()
dirver.maximize_window()
dirver.get("https://work.weixin.qq.com/wework_admin/loginpage_wx")
time.sleep(20)
cookies = dirver.get_cookies()
with open("./cookies.yaml","w",encoding="utf-8") as file:
    yaml.safe_dump(cookies, file)
print(cookies)


# def test_set_cookies():
#     dirver = webdriver.Chrome()
#     dirver.maximize_window()
#     dirver.get("https://work.weixin.qq.com/wework_admin/loginpage_wx")
#     with open("./cookies.yaml","r",encoding="utf-8") as file:
#         cookies = yaml.safe_load( file)
#     for cookie in cookies:
#         dirver.add_cookie(cookie)
#     dirver.refresh()
#     time.sleep(5)





